#ifndef DTSTRING_H
#define DTSTRING_H

#include "Object.h"
#include "Exception.h"
namespace DSLib
{

class String : public Object
{
protected:
	char* m_str;
	int m_length;

	void init(const char* s);
	bool equal(const char* l, const char* r, int len) const;
public:
	String();
	String(const char* s);
	String(const char c);
	String(const String& s);
	const char* str() const;
	int length() const;
	
	String& trim();
	String& insert(int i, const String& s);
	String& insert(int i, const char* s);
	bool startWith(const String& s) const;
	bool startWith(const char* s) const;
	bool endOf(const String& s) const;
	bool endOf(const char* s) const;

	char& operator [] (int i);
	char operator[] (int i) const;

	bool operator == (const String& s) const;
	bool operator == (const char* s) const;
	bool operator != (const String& s) const;
	bool operator != (const char* s) const;
	bool operator > (const String& s) const;
	bool operator > (const char* s) const;
	bool operator < (const String& s) const;
	bool operator < (const char* s) const;
	bool operator >= (const String& s) const;
	bool operator >= (const char* s) const;
	bool operator <= (const String& s) const;
	bool operator <= (const char* s) const;

	String& operator = (const String& s);
	String& operator = (const char* s);
	String& operator = (const char c);

	String operator + (const String& e) const;
	String operator + (const char* s) const;
	String operator + (const char c) const;

	String& operator += (const String& s);
	String& operator += (const char* s);
	String& operator += (const char c);

	~String();
};

}






#endif